package com.demoweb.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.demoweb.model.dao.BoardDao;
import com.demoweb.model.dao.MemberDao;
import com.demoweb.model.dto.BoardComment;

@WebServlet("/board/deletecomment.action")
public class BoardCommentDeleteServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		//1. 댓글번호 읽어서 변수에 저장
		int commentNo = Integer.parseInt(req.getParameter("commentno"));
		
		//2. 댓글번호에 해당하는 댓글 삭제
		BoardDao dao = new BoardDao();
		dao.deleteComment(commentNo);
		
		//3. view.action로 이동
		resp.sendRedirect(
			"view.action?" + 
			"boardno=" + req.getParameter("boardno") + 
			"&pageno=" + req.getParameter("pageno"));
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		doGet(req, resp);
	}
	
}




